#coding:utf-8
'''
Created on 2015年4月20日

@author: leoZ
'''

from com.cyou.com.DBUtils import DBUtils
#JobSource
class EtlJobSourceEntity(object):
    def __init__(self,source,etlSystemName,etlJobName,convertFileHeader,beforeHour,beforeMin,offsetDay,extra,myId):
        self.source = source
        self.etlSystemName = etlSystemName
        self.etlJobName = etlJobName
        self.convertFileHeader = convertFileHeader
        self.beforeHour = beforeHour
        self.beforeMin = beforeMin
        self.offsetDay = offsetDay
        self.extra = extra
        self.myId = myId
#Dao
class EtlJobSourceDao(object):
    def loadAllJobSource(self):
        connection = DBUtils().getConnection()
        cursor = connection.cursor()
        cursor.execute("select * from etl_job_source")
        cursor.rowfactory = EtlJobSourceEntity
        return cursor.fetchall()
    #通过系统名和任务明，返回符合条件的jobSource
    def loadAllJobSourceByJobName(self,etlSystemName,etlJobName):
        connection = DBUtils().getConnection()
        cursor = connection.cursor()
        sql = "select * from etl_job_source where ETLSYSTEMNAME = '%s' and ETLJOBNAME = '%s'" % (etlSystemName,etlJobName)
        cursor.execute(sql)
        cursor.rowfactory = EtlJobSourceEntity
        return cursor.fetchall()
    #通过系统源，返回符合条件的jobSource。主要用于查询一个文件下载后。相关的文件有那些
    def loadAllJobSourceBySource(self,source):
        connection = DBUtils().getConnection()
        cursor = connection.cursor()
        sql = "select * from etl_job_source where SOURCE = '%s'" % (source)
        cursor.execute(sql)
        cursor.rowfactory = EtlJobSourceEntity
        return cursor.fetchall()   